// import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
import QtQuick 1.1
import "../Components"

GroupBox {
    id: _root
    width: _area.width + 20
    height: _area.height + _area.anchors.topMargin + 5

    text: qsTr("  Control Panel  ")
    textBkSource: "../images/background.png"
    borderColor: "#888888"
    borderBkColor: "#00000000"
    radius: 5
    color: "#dddddd"

    property alias enabledBootButton: _boot.enabled
    property alias enabledRebootButton: _reboot.enabled
    property bool isPortrait: true      //現在の画面の向き

    signal screenLock(bool is)
    signal takeScreenShot()
    signal boot()
    signal reboot()
    signal rotated(int r)

    signal wifiSignalChanged(int num)
    signal isWifiSignalFullyChanged(bool is)
    signal wifiDirectionChanged(int num)
    signal batteryChargeChanged(int num)
    signal isBatteryChargeChanged(bool is)

    signal numberOfHomeScreen(int num)

    Column{
        id: _area
        anchors.top: parent.top
        anchors.topMargin: parent.textHeight + 5
        anchors.left: parent.left
        anchors.leftMargin: 10

        spacing: 5

        Button{
            text: "  Lock  "
            onClicked: {
                _root.screenLock(true);
            }
        }
        Button{
            text: " ScreenShot "
            onClicked: {
                _root.takeScreenShot();
            }
        }
        Button{
            id: _boot
            text: " Boot "
            enabled: false
            onClicked: {
                _root.boot();
            }
        }

        Button{
            id: _reboot
            text: " Reboot "
            enabled: false
            onClicked: {
                _root.reboot();
            }
        }

        Button{
            id: _rotation
            text: " Rotation "//isPortrait ? " To Land " : " To Port "
            enabled: true
            onClicked: {
                _root.rotated(!isPortrait);
            }
        }

        //wifiの通信方向
        SliderAndSelector{
            text: qsTr("  Wifi  ")
            max: 4
            min: 0
            Component.onCompleted: {
                currentValue = 2;
            }
            model: ListModel{
                ListElement{_key: -1; _text: "Stop"}
                ListElement{_key: 0; _text: "In"}
                ListElement{_key: 1; _text: "Out"}
                ListElement{_key: 2; _text: "In/Out"}
            }
            model2: ListModel{
                ListElement{_key: 0; _text: "Normal"}
                ListElement{_key: 1; _text: "Full"}
            }
            onCurrentValueChanged: {
                _root.wifiSignalChanged(currentValue);
            }
            onCurrentKeyChanged: {
                _root.wifiDirectionChanged(currentKey);
            }
            onCurrentKey2Changed: {
                if(currentKey2 == 0){
                    _root.isWifiSignalFullyChanged(false);
                }else{
                    _root.isWifiSignalFullyChanged(true);
                }
            }
        }
        //バッテリー
        SliderAndSelector{
            text: qsTr("  Battery  ")
            max: 100
            min: 0
            sliderHeight: 100
            Component.onCompleted: {
                currentValue = 50;
            }

            model: ListModel{
                ListElement{_key: 0; _text: "None"}
                ListElement{_key: 1; _text: "Charge"}
            }
            onCurrentValueChanged: {
                _root.batteryChargeChanged(currentValue);
            }
            onCurrentKeyChanged: {
                if(currentKey == 0){
                    _root.isBatteryChargeChanged(false);
                }else{
                    _root.isBatteryChargeChanged(true);
                }
            }
        }
        //ホームスクリーンの数
        GroupBox{
            width: 1.2 * (_numberOfHomescreen.width > textArea.width ? _numberOfHomescreen : textArea.width)
            text: qsTr("Number of homescreen")
            textBkSource: "../images/background.png"
            borderColor: "#888888"
            borderBkColor: "#00000000"
            radius: 5
            color: "#dddddd"
            height: _numberOfHomescreen.height + textHeight * 1.5
            RadioBox{
                id: _numberOfHomescreen
                anchors.top: parent.top
                anchors.margins: parent.textHeight * 1.2
                anchors.left: parent.left
                anchors.leftMargin: 5
                fontColor: "#ffffff"
                currentIndex: 2
                model: ListModel{
                    ListElement{_key: 1; _text: "1"}
                    ListElement{_key: 3; _text: "3"}
                    ListElement{_key: 5; _text: "5(default)"}
                    ListElement{_key: 7; _text: "7"}
                }
                onCurrentKeyChanged: {
                    _root.numberOfHomeScreen(currentKey);
                }
            }
        }

    }
}
